package com.cnsdhh.listener;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

//监听类必须实现MessageListener接口
public class MyMessageListener implements MessageListener {
    //监听消息，当监听到消息的时候会调用此方法，message存放接受的消息
    public void onMessage(Message message) {
        TextMessage textMessage=(TextMessage)message;
        try {
            System.out.println("接收到消息："+textMessage.getText());
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}
